using Microsoft.AspNetCore.Mvc;
using MESData.ErrorCode;
using MESData.ProductionPlan.API.DTO;
using MESData.ProductionPlan.API.Services;

namespace MESData.ProductionPlan.API.Controllers
{
    /// <summary>
    /// 销售订单控制器
    /// </summary>
    [ApiController]
    [Route("api/[controller]")]
    public class SalesOrderController : ControllerBase
    {
        private readonly ISalesOrderService _salesOrderService;

        public SalesOrderController(ISalesOrderService salesOrderService)
        {
            _salesOrderService = salesOrderService;
        }

        /// <summary>
        /// 分页查询所有销售订单
        /// </summary>
        [HttpPost("query")]
        public async Task<ApiPageing<SalesOrderResultDto>> GetSalesOrders([FromBody] SalesOrderQueryDto queryDto)
        {
            return await _salesOrderService.GetSalesOrdersAsync(queryDto);
        }

        /// <summary>
        /// 根据销售订单ID查询多个物品的分页条件查询列表
        /// </summary>
        [HttpPost("items")]
        public async Task<ApiPageing<SalesOrderItemResultDto>> GetSalesOrderItems([FromBody] SalesOrderItemQueryDto queryDto)
        {
            return await _salesOrderService.GetSalesOrderItemsAsync(queryDto);
        }
    }
} 